<h1><code ng:non-bindable="">$filterProvider</code>
<span class="hint">(service in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><a href="http://github.com/angular/angular.js/edit/master/src/ng/filter.js" class="improve-docs btn btn-primary">Improve
    this doc</a>

    <h2 id="Description">Description</h2>

    <div class="description">
        <div class="ng-filterprovider-page"><p>Filters are just functions which transform input to an output. However
            filters need to be Dependency Injected. To
            achieve this a filter definition consists of a factory function which is annotated with dependencies and is
            responsible for creating a filter function.</p>

<pre class="prettyprint linenums">
  // Filter registration
  function MyModule($provide, $filterProvider) {
    // create a service to demonstrate injection (not always needed)
    $provide.value('greet', function(name){
      return 'Hello ' + name + '!';
    });

    // register a filter factory which uses the
    // greet service to demonstrate DI.
    $filterProvider.register('greet', function(greet){
      // return the filter function which uses the greet service
      // to generate salutation
      return function(text) {
        // filters need to be forgiving so check input validity
        return text && greet(text) || text;
      };
    });
  }
</pre>

            <p>The filter function is registered with the <code>$injector</code> under the filter name suffixe with
                <code>Filter</code>.
<pre class="prettyprint linenums">
  it('should be the same instance', inject(
    function($filterProvider) {
      $filterProvider.register('reverse', function(){
        return ...;
      });
    },
    function($filter, reverseFilter) {
      expect($filter('reverse')).toBe(reverseFilter);
    });
</pre>

            <p>For more information about how angular filters work, and how to create your own filters, see
                <a href="guide/dev_guide.templates.filters">Understanding Angular Filters</a> in the angular Developer
                Guide.</p></div>
    </div>
    <div class="member method"><h2 id="Methods">Methods</h2>
        <ul class="methods">
            <li><h3 id="register">register(name, fn)</h3>

                <div class="register">
                    <div class="ng-filterprovider-register-page"><p>Register filter factory function.</p></div>
                    <h4 id="Parameters">Parameters</h4>
                    <ul class="parameters">
                        <li><code ng:non-bindable="">name – {String} – </code>

                            <div class="ng-filterprovider-register-page"><p>Name of the filter.</p></div>
                        </li>
                        <li><code ng:non-bindable="">fn – {function} – </code>

                            <div class="ng-filterprovider-register-page"><p>The filter factory function which is
                                injectable.</p></div>
                        </li>
                    </ul>
                </div>
            </li>
        </ul>
    </div>
</div>
